﻿using System;
using System.Collections.Generic;

namespace ApprovalFlow.Models
{
    /// <summary>
    /// 工作流的实例对象
    /// </summary>
    public class WorkflowInstance
    {
        /// <summary>
        /// 实例id
        /// </summary>
        public string InstanceId { get; set; }

        /// <summary>
        /// 模板代码
        /// </summary>
        public string ProcessCode { get; set; }

        public int Version { get; set; }

        public string Description { get; set; }

        public string Reference { get; set; }

        public ExecutionPointerCollection ExecutionPointers { get; set; } = new ExecutionPointerCollection();

        /// <summary>
        /// 下一个步骤
        /// </summary>
        public string NextExecution { get; set; }

        /// <summary>
        /// 关联的数据对象
        /// </summary>
        public object Data { get; set; }

        /// <summary>
        /// 运行过程中产生的数据对象
        /// </summary>
        public Dictionary<string, object> Variable { get; set; } = new Dictionary<string, object>();

        /// <summary>
        /// 发起用户id
        /// </summary>
        public string UserID { get; set; }

        /// <summary>
        /// 发起用户所属的部门id
        /// </summary>
        public string DeptID { get; set; }

        /// <summary>
        /// 指定步骤节点的用户信息。
        /// </summary>
        public Dictionary<string, string[]> CustomUserList { get; set; }

        /// <summary>
        /// 抄送人列表
        /// </summary>
        public string[] CCList { get; set; }

        /// <summary>
        /// 抄送的节点
        /// </summary>
        public string CCPosition { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; }

        /// <summary>
        /// 完成时间
        /// </summary>
        public DateTime? CompleteTime { get; set; }

        /// <summary>
        /// 状态
        /// </summary>
        public WorkflowStatus Status { get; set; }
    }

    public enum WorkflowStatus
    {
        /// <summary>
        /// 运行中
        /// </summary>
        Runnable = 0,

        /// <summary>
        /// 完成
        /// </summary>
        Completed = 1,

        /// <summary>
        /// 被终止
        /// </summary>
        Terminated = 2,

        /// <summary>
        /// 取消
        /// </summary>
        Canceled = 3,
    }
}
